package com.bo.rabbit.controller;

import com.bo.rabbit.common.RestResponse;
import com.bo.rabbit.entity.Category;
import com.bo.rabbit.entity.Document;
import com.bo.rabbit.service.CategoryService;
import com.bo.rabbit.service.DocumentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @program rabbit
 * @Description 上传文件
 * @Author Diviner
 * @Date 2024/03/27 13:23
 * @Version 1.0
 */
@Api("文件接口")
@RestController
@RequestMapping("/document")
public class DocumentController {
    @Autowired
    private DocumentService documentService;
    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public RestResponse uploadDocument(@RequestParam("file") MultipartFile file){
        if (file ==null){
            return RestResponse.validFail("请上传图片");
        }
        RestResponse response=documentService.uploadDocument(file);

        return response;
    }
}
